package com.czl.category.test.entity.common;

import com.github.pagehelper.PageHelper;
import lombok.Data;
import org.apache.commons.lang.math.NumberUtils;

/**
 * TODO
 *
 * @author yugt
 * @description
 * @date 2021/1/19 9:51
 */
@Data
public class PageParam {
    private static final int DEFAULT_PAGE_NO = 1;

    private static final int DEFAULT_PAGE_SIZE = 10;

    private String pageNo;

    private String pageSize;

    public void startPage() {
        int pageNoEx;
        if (NumberUtils.isNumber(pageNo)) {
            pageNoEx = NumberUtils.toInt(pageNo);
            pageNoEx = pageNoEx > 0 ? pageNoEx : DEFAULT_PAGE_NO;
        } else {
            pageNoEx = DEFAULT_PAGE_NO;
        }
        int pageSizeEx;
        if (NumberUtils.isNumber(pageSize)) {
            pageSizeEx = NumberUtils.toInt(pageSize);
            pageSizeEx = pageSizeEx > 0 ? pageSizeEx : DEFAULT_PAGE_SIZE;
        } else {
            pageSizeEx = DEFAULT_PAGE_SIZE;
        }
        PageHelper.startPage(pageNoEx, pageSizeEx);
    }

    public static void main(String[] args) {

    }

}
